package com.xy.repository;
import com.xy.entity.Coupon.Coupon;
import com.xy.entity.User;
import org.hibernate.sql.Select;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * Date: 2018-01-20
 * Time: 15:04
 */
public interface CouponRespository extends JpaRepository<Coupon,User> {

    @Query(value = "Select '*' from  Coupon c right join user_coupons uc ON c.uuid = uc.couponsUuid RIGHT JOIN User u on uc.userUuid = u.uuid where u.uuid =?1",nativeQuery =true)
    Coupon findByUserId(String userId);

}
